<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>前置征信记录管理</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<body class="iframeBody">
    <div class="Wrapper">
    	<div class="searchArea">
	        <form id="searchBar">
	            <div class="fieldset1 clearFix">
	                <div class="fieldBox">
	                    <div class="label">客户姓名</div>
	                    <div class="field">
	                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
	                    </div>
	                </div>
	                <div class="fieldBox">
	                    <div class="label">手机号</div>
	                    <div class="field">
	                        <input name="mp" id="mp" type="text" class="ui-textbox" value="">
	                    </div>
	                </div>
	                <div class="fieldBox">
	                    <div class="label">商家名称</div>
	                    <div class="field">
	                        <input name="splNm" id="splNm" type="text" class="ui-textbox" value="">
	                    </div>
	                </div>
	                <div class="fieldBox">
			            <div class="label">是否停止审核</div>
			               <div class="field">
			               <select name="isDl" id="isDl" data-value="">
			               	   <option value="" selected="selected">请选择</option>
			                   <c:forEach items="${YNCdList }" var="kv">
									<option value="${kv.key }">${kv.value }</option>
							   </c:forEach>
			               </select>
			            </div>
			        </div>
	                <div class="clearFix"></div>
	                <div class="btnsBox formBtns notRight">
	                    <span id="searchBtn" class="sq-button-round">查询</span>
	                    <span id="clearBtn" class="sq-button-round">清空</span>
	                    <span id="audSelectedBtn" class="sq-button-round">征信审核</span>
	                    <span id="audAllDlBtn" class="sq-button-round">全部征信审核(停止审核)</span>
	                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
	                </div>
	            </div>
	        </form>
    	</div>
        <div class="sqPanel">
            <div class="sqPanel_body">
                <div id="rc_cst_bsc_grid_id" class="sq-grid"></div>
            </div>
        </div>
    </div>

    <script>
    var pathValue = null ;
    $(function() {
    	initForm();
    	initGrid();
    	initEvent();
    });
    
    function initEvent(){
    	//查询
    	$("#searchBtn").click(function (event) {
    		reLoad();
        });
    	
    	//审核
    	$("#audSelectedBtn").click(function (event) {
    		var selectedRows = grid.getSelectedRows();
    		if(selectedRows.length == 0){
    			UIUtils.alertWarning(LogUtils.LOG_CMM_SELECT_MORE_ROW);
    			return;
    		}
    		var _ids = [];
    		for ( var index in selectedRows) {
    			_ids.push(selectedRows[index].id);
    		}
    		
    		var _url = "<%=path%>/riskctrl/rccstbscinfo/audRcCstBscInfoByIds.do";
    		var _params = {
    				ids:JSON.stringify(_ids)
    		};
    		AjaxUtils.ajaxPostWithSQconfirm(_url, _params, function(data){
    			if(data.success == 1){
    				reLoad();
				 }else{
					 UIUtils.alertError(data.info);
				 }
    		}, true, "确定审核吗?");
        });

    	//全部审核(已死亡)
    	$("#audAllDlBtn").click(function (event) {
    		var _url = "<%=path%>/riskctrl/rccstbscinfo/audIsDlRcCstBscInfoByIds.do";
    		var _params = {};
    		AjaxUtils.ajaxPostWithSQconfirm(_url, _params, function(data){
    			if(data.success == 1){
    				reLoad();
				 }else{
					 UIUtils.alertError(data.info);
				 }
    		}, true, "确定全部审核已死亡数据吗?");
        });
    }
    
    function initForm(){
    	$("#searchBar").ligerForm();
    }
    
    function initGrid(){
    	//初始化Grid
        $("#rc_cst_bsc_grid_id").ligerGrid({
            usePager: true,
            url: "<%=path%>/riskctrl/rccstbscinfo/initRcCstBscInfoMgtList.do",
            method : 'get',
            columns: [{display: '主键', name: 'id', align: 'left', width: 120, hide:true},
                      {display: '客户姓名', name: 'cstNm', align: 'left', width: 100},
                      {display: '手机号', name: 'mp1', align: 'center', width: 100},
                      {display: '证件号', name: 'certNo', align: 'center', width: 150},
                      {display: '客户类型', name: 'cstTypCdNm', align: 'center', width: 100},
                      {display: '购车类型', name: 'prdTypCdNm', align: 'center', width: 150},
                      /* {display: '贷款额（元）',name: 'prdAmt', align: 'left', width: 150}, */
                      {display: '评审状态', name: 'audStsCdNm', align: 'center', width: 100},
                      {display: '是否复议', name: 'isReaudNm', align: 'center', width: 100},
                      {display: '评审结果', align: 'center', width: 200, 
                    	  render:function (rowdata, rowindex, value){
                    	  		return UIUtils.showColumnTip(rowdata.audStsDesc);
                      	  }
                      },
                      {display: '评审结果1', align: 'left', width: 150, 
                    	  render:function (rowdata, rowindex, value){
                      	  		return UIUtils.showColumnTip(rowdata.audStsDesc2);
                          }
                      },
                      {display: '是否停止审核', name: 'isDl', align: 'center', width: 80,
                    	  render:function (rowdata, rowindex, value){
                    	  		var tip = "";
                    	  		if(rowdata.isDl == 1){
                    	  			tip = "是";
                    	  		}else{
                    	  			tip = "否";
                    	  		}
                    	  		return tip;
                          }
                      },
                      {display: '用户级别', name: 'rskLvlCdNm', align: 'center', width: 80},
                      {display: '是否有担保人', name: 'isHasDbr', align: 'center', width: 80,
                    	  render:function (rowdata, rowindex, value){
                    	  		var tip = "";
                    	  		if(rowdata.isHasDbr == 1){
                    	  			tip = "是";
                    	  		}else{
                    	  			tip = "否";
                    	  		}
                    	  		return tip;
                          }
                      },
                      {display: '经销商', name: 'splNm', align: 'left', width: 150},
                      {display: '业务员', name: 'crtNm', align: 'left', width: 80},
                      {display: '客户经理', name: 'cstMgrNm', align: 'center', width: 80},
                      
                      {display: '查询次数', name: 'srchQty', align: 'center', width: 80},
                      {display: '是否通知', name: 'isNotify', align: 'center', width: 80,
                    	  render:function (rowdata, rowindex, value){
                  	  		var tip = "";
                  	  		if(rowdata.isNotify == 1){
                  	  			tip = "是";
                  	  		}else{
                  	  			tip = "否";
                  	  		}
                  	  		return tip;
                        }
                      },
                      {display: '通知次数', name: 'notifyQty', align: 'center', width: 80},
                      {display: '活体分数', name: 'livScore', align: 'center', width: 80},
                      {display: '活体审核状态', name: 'livAudStsCdNm', align: 'center', width: 100},
                      {display: '数据来源', name: 'dsCdNm', align: 'center', width: 100},
                      
                      {display: '备注', name: 'cstRem', align: 'left', width: 150},
                      {display: '所属机构', name: 'cstMgrOrgCdNm', align: 'left', width: 200},
                      {display: '省公司', name: 'prOrgCdNm', align: 'center', width: 150},
                      {display: '分公司', name: 'cyOrgCdNm', align: 'left', width: 150},
                      /* {display: '行驶证', name: 'driveIdHolderCdNm', align: 'center', width: 200}, */
                      /* {display: '婚姻状况', name: 'marStsCdNm', align: 'center', width: 100}, */
                      /* {display: '配偶/担保人信息', name: '', align: 'left', width: 150}, */
                      {display: '授权书', align: 'left', width: 150,
                          render: function (rowdata, rowindex, value){
                              var h;
                              h='<a href="javascript:uploadFileByUrl(';
                              h+="'"+rowdata.authFilePath+"'";
                              h+=",'"+rowdata.authFileNm+"'";
                              h+=')">'+rowdata.authFileNm+'</a>'
                              return h;
                          }
                      },
                      {display: '电子征信授权书', name: 'zxFilePath', align: 'center', width: 110,
                    	  render:function (rowdata, rowindex, value, column) {
                      		if(rowdata.zxFilePathStatus == 1){
	                      		return '<a href="javascript:toGetPath('+"'"+rowdata.id+"'"+');" >查看征信授权书</a>';
                      		}
                      	}
                      },
                      {display: '短信状态', name: 'mpMsgCdNm', align: 'center', width: 150,
                    	   
                      },
                      {display: '短信内容', name: 'mpMsgDesc', align: 'left', width: 150},
                      {display: '身份证', align: 'center', width: 100,
                          render: function (rowdata, rowindex, value){
                              var h;
                              h='<a href="javascript:uploadFileByUrl(';
                              h+="'"+rowdata.idCardFilePath+"'";
                              h+=",'"+rowdata.idCardFileNm+"'";
                              h+=')">'+rowdata.idCardFileNm+'</a>'
                              return h;
                          }
                      },
                      {display: '时间', name: 'crtTm', align: 'center', width: 150, render: renderDate}
                  ],
            width: '100%',
            isScroll: false,
            height:'100%',
			heightDiff:-2,
            root:'rows',
	        record:'total',
	        checkbox:true,
	        frozen: false,
            rownumbers: true,
            fixedCellHeight: false,
            usePagerOnLessPagesize: false,
            
	        allowUnSelectRow: true,
            alternatingRow: false,
            onBeforeShowData: function ()
            {
                var grid = this;
                grid.collapsedRows = [];
            },
            detail: {
                height: 'auto',
                onShowDetail: showDetail_grid
            }
        });
        grid = liger.get("rc_cst_bsc_grid_id");
        grid.options.isSingleCheck=false;
        grid.setHeight(500);
    }
    
  	//详情
    <%-- function cstCommRecDetail(_id){
    	$.ligerDialog.open({
            cls: 'noBorder_Dialog',
            width: 800,
            height:380,
            title : '详情',
            url:'<%=path%>/customer/cstcommrec/toDetailPage.do?id='+_id,
         	// 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
    } --%>
    
  	//Grid操作列
    function getGridOperColumnContent(){
    	var data = {
                display: '操作',
                isSort: false,
                width: 70,
                render: function (rowdata, rowindex, value){
                	if(rowdata.isOper == 0) return "";
                    var h='<a class="sq-button-hasicon" href="javascript:deleteRow(';
                        h+="'"+rowdata.id+"'";
                        h+=")\"><i class=\"sqBtnIco_7\"></i>"+LogUtils.LOG_CMM_GRID_BTN_DELETE+"</a>"
                    return h;
                }
            }
    	return data;
	}
  	//客户关系明细列表
    function showDetail_grid(row, detailPanel, callback){
        var gridBox = document.createElement('div');
        $(gridBox).css('margin', 10);
        $(detailPanel).css({
            'padding': 10,
            'box-sizing': 'border-box'
        }).append(gridBox);
        detailGrid = $(gridBox).ligerGrid({
        	url: '<%=path%>/riskctrl/rccstbscinfo/initCstSocialList.do?cstId='+ row.id,
            method: 'get',
            columns: [
                {display: '姓名',name: 'rlNm',width: 180,align:'center'},
                {display: '性别', name: 'genderCdNm', width: 50, align: 'center'},
                {display: '客户关系', name: 'rlTypCdNm', width: 80, align: 'center'},
                {display: '出生日期',name: 'birthdayStr',width: 150,align:'center'},
                {display: '证件类型',name: 'certTypCdNm', width: 100,align:'center',},
                {display: '证件号', name: 'certNo', width: 180, align: 'center'},
                {display: '手机号码(1)', name: 'mp1', width: 180, align: 'center'},
                {display: '手机号码(2)', name: 'mp2', width: 180, align: 'center'},
                {display: '授权书', align: 'center', width: 150,
                    render: function (rowdata, rowindex, value){
                        var h;
                        h='<a href="javascript:uploadFileByUrl(';
                        h+="'"+rowdata.authFilePath+"'";
                        h+=",'"+rowdata.authFileNm+"'";
                        h+=')">'+rowdata.authFileNm+'</a>'
                        return h;
                    }
                },
                /* {display: '电子征信授权书', name: 'zxFilePath', align: 'center', width: 110,
              	  render:function (rowdata, rowindex, value, column) {
	              		if(rowdata.zxFilePathStatus == 1){
	              			return '<a href="javascript:toGetPath('+"'"+rowdata.id+"'"+');" >查看征信授权书</a>';
	              		}
                	}
                }, */
                {display: '身份证', align: 'center', width: 100,
                    render: function (rowdata, rowindex, value){
                        var h;
                        h='<a href="javascript:uploadFileByUrl(';
                        h+="'"+rowdata.idCardFilePath+"'";
                        h+=",'"+rowdata.idCardFileNm+"'";
                        h+=')">'+rowdata.idCardFileNm+'</a>'
                        return h;
                    }
                },
            ],
            root: 'rows',
            hideLoadButton : true,
            width: '100%',
            height: 'auto',
            isScroll: false,
            rownumbers:true,  //显示序号
            allowUnSelectRow:true,
            alternatingRow: false,
            onAfterShowData: callback,
            frozen: false,
            usePager: false
        });
    }
    //删除信息
    function deleteRow(_id) {
    	$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;
			var _url = "";
			AjaxUtils.ajaxPost(_url, {id:_id}, function(data){
				
			}, true);
			
			$.ajax({
	     		type: 'post',
	     		dataType:'json',
	     		data:{id:_id},
	     		url: '<%=path%>/customer/cstcommrec/removeById.do',
	     		success:function(msg){
	     			wait_dialog.close();
	     			 if(msg.success == 1){
	     				$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
	     				grid.setParm("cstId",cstId);
	     				grid.reload();
	     			 }else{
	     				$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	     			 }
	     		}
	     	});
		});
    }
    
    //重新加载
    function reLoad(){
    	var form = new liger.get("searchBar");
        var data = form.getData();
        for (name in data) {
            grid.setParm(name, data[name]);
        }
        grid.reload();
    }
    
    //格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}
    
    function uploadFileByUrl(_url,_name){
        if(SQ.regs.img.test(_name)){
            window.__ImgSrc = _url;
            window.__ImgTit = _name;
            window.open('<%=path%>/project/prjbscinfo/imgWinOpen.do', '', 'location=yes, width=800, height=600');
        }else{
            window.open(_url);
        }
    }
    
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	function toGetPath(id){
    	$.ajax({
            type: 'get',
            dataType: 'json',
            url: '<%=path%>/riskctrl/rccstbscinfo/getFilPath.do?filId='+id,
            success: function (msg) {
                if (msg.success == 1) {
                	window.open(msg.info)
                } else {
                	$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }
    </script>
</body>

</html>
